package com.api.server.pojo;

import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import java.io.Serializable;
import java.util.Collection;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

/**
 * <p>
 * 
 * </p>
 *
 * @author shi
 * @since 2022-04-28
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("yh_user")
@ApiModel(value="User对象", description="")
public class User implements Serializable, UserDetails {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "序号")
    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;

    @ApiModelProperty(value = "身份证号")
    private String userid;

    @ApiModelProperty(value = "账号")
    private String useraccount;

    @ApiModelProperty(value = "名字")
    private String username;

    @ApiModelProperty(value = "联系电话")
    private String usernumber;

    @ApiModelProperty(value = "钱包")
    private Float userwallet;

    @ApiModelProperty(value = "个性签名")
    private String usersignature;

    @ApiModelProperty(value = "密码")
    private String userpassword;

    @ApiModelProperty(value = "失败订单编号")
    private String pendingorders;

    @ApiModelProperty(value = "已完成订单编号")
    private String completedorder;

    @ApiModelProperty(value = "权限等级")
    private String usergrade;

    @ApiModelProperty(value = "状态")
    private String state;
    private boolean enabled(){
        if (state=="0"){
            return true;
        }
        return false;
    }

    @ApiModelProperty(value = "所属部门")
    private String controllerdepartment;

    @ApiModelProperty(value = "所属管理单位")
    private String controllerunit;

    @ApiModelProperty(value = "所属管理单位单位标识号")
    private String controllerunitnumber;

    @ApiModelProperty(value = "职位")
    private String controllerposition;

    @ApiModelProperty(value = "待处理订单")
    private String controllerpendingorders;

    @ApiModelProperty(value = "已处理订单")
    private String controllerordersprocessed;


    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return null;
    }

    @Override
    public String getUsername() {
        return useraccount;
    }

    @Override
    public String getPassword() {
        return userpassword;
    }

    @Override
    public boolean isAccountNonExpired() {
        return true;
    }

    @Override
    public boolean isAccountNonLocked() {
        return true;
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    }

    @Override
    public boolean isEnabled() {
        return enabled();
    }
}
